using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
using System.Xml.Serialization;
using XCode;
using XCode.Configuration;
using XCode.DataAccessLayer;

namespace XCode.Membership
{
    /// <summary>小说目录</summary>
    [Serializable]
    [DataObject]
    [Description("小说目录")]
    [BindIndex("IX_TXiaoshuo_Name", false, "Name")]
    [BindIndex("IX_TXiaoshuo_UpdateTime", false, "UpdateTime")]
    [BindTable("TXiaoshuo", Description = "小说目录", ConnName = "XSConn", DbType = DatabaseType.None)]
    public partial class TXiaoshuo
    {
        #region 属性
        private Int64 _ID;
        /// <summary>编号</summary>
        [DisplayName("编号")]
        [Description("编号")]
        [DataObjectField(true, false, false, 0)]
        [BindColumn("ID", "编号", "")]
        public Int64 ID { get => _ID; set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } } }

        private String _Name;
        /// <summary>名称</summary>
        [DisplayName("名称")]
        [Description("名称")]
        [DataObjectField(false, false, false, 50)]
        [BindColumn("Name", "名称", "", Master = true)]
        public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }

        private String _Author;
        /// <summary>名称</summary>
        [DisplayName("作者")]
        [Description("作者")]
        [DataObjectField(false, false, true, 50)]
        [BindColumn("Author", "作者", "")]
        public String Author { get => _Author; set { if (OnPropertyChanging("Author", value)) { _Author = value; OnPropertyChanged("Author"); } } }

        private String _BaseUrl;
        /// <summary>源地址</summary>
        [DisplayName("源地址")]
        [Description("源地址")]
        [DataObjectField(false, false, true, 50)]
        [BindColumn("BaseUrl", "源地址", "")]
        public String BaseUrl { get => _BaseUrl; set { if (OnPropertyChanging("BaseUrl", value)) { _BaseUrl = value; OnPropertyChanged("BaseUrl"); } } }

        private String _Url;
        /// <summary>url地址</summary>
        [DisplayName("url地址")]
        [Description("url地址")]
        [DataObjectField(false, false, true, 50)]
        [BindColumn("Url", "url地址", "")]
        public String Url { get => _Url; set { if (OnPropertyChanging("Url", value)) { _Url = value; OnPropertyChanged("Url"); } } }

        private DateTime _UpdateTime;
        /// <summary>更新时间</summary>
        [DisplayName("更新时间")]
        [Description("更新时间")]
        [DataObjectField(false, false, false, 0)]
        [BindColumn("UpdateTime", "更新时间", "")]
        public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging("UpdateTime", value)) { _UpdateTime = value; OnPropertyChanged("UpdateTime"); } } }

        private String _Remark;
        /// <summary>备注</summary>
        [DisplayName("备注")]
        [Description("备注")]
        [DataObjectField(false, false, true, 200)]
        [BindColumn("Remark", "备注", "")]
        public String Remark { get => _Remark; set { if (OnPropertyChanging("Remark", value)) { _Remark = value; OnPropertyChanged("Remark"); } } }


        private Int32 _IsXiaoshuo;
        /// <summary>是否是小说</summary>
        [DisplayName("是否是小说")]
        [Description("是否是小说")]
        [DataObjectField(false, false, false, 0)]
        [BindColumn("IsXiaoshuo", "是否是小说", "")]
        public Int32 IsXiaoshuo { get => _IsXiaoshuo; set { if (OnPropertyChanging("IsXiaoshuo", value)) { _IsXiaoshuo = value; OnPropertyChanged("IsXiaoshuo"); } } }

        #endregion

        #region 获取/设置 字段值
        /// <summary>获取/设置 字段值</summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        public override Object this[String name]
        {
            get
            {
                switch (name)
                {
                    case "ID": return _ID;
                    case "Name": return _Name;
                    case "Author": return _Author;
                    case "BaseUrl": return _BaseUrl;
                    case "Url": return _Url;
                    case "UpdateTime": return _UpdateTime;
                    case "Remark": return _Remark;
                    case "IsXiaoshuo": return _IsXiaoshuo;
                    default: return base[name];
                }
            }
            set
            {
                switch (name)
                {
                    case "ID": _ID = value.ToLong(); break;
                    case "Name": _Name = Convert.ToString(value); break;
                    case "Author":
                        _Author = Convert.ToString(value); break;
                    case "BaseUrl": _BaseUrl = Convert.ToString(value); break;
                    case "Url": _Url = Convert.ToString(value); break;
                    case "UpdateTime": _UpdateTime = value.ToDateTime(); break;
                    case "Remark": _Remark = Convert.ToString(value); break;
                    case "IsXiaoshuo":
                        _IsXiaoshuo = value.ToInt(); break;
                    default: base[name] = value; break;
                }
            }
        }
        #endregion

        #region 字段名
        /// <summary>取得小说目录字段信息的快捷方式</summary>
        public partial class _
        {
            /// <summary>编号</summary>
            public static readonly Field ID = FindByName("ID");

            /// <summary>名称</summary>
            public static readonly Field Name = FindByName("Name");//Author
            public static readonly Field Author = FindByName("Author");//Author

            /// <summary>源地址</summary>
            public static readonly Field BaseUrl = FindByName("BaseUrl");

            /// <summary>url地址</summary>
            public static readonly Field Url = FindByName("Url");

            /// <summary>更新时间</summary>
            public static readonly Field UpdateTime = FindByName("UpdateTime");

            /// <summary>备注</summary>
            public static readonly Field Remark = FindByName("Remark");
            public static readonly Field IsXiaoshuo = FindByName("IsXiaoshuo");
            static Field FindByName(String name) => Meta.Table.FindByName(name);
        }

        /// <summary>取得小说目录字段名称的快捷方式</summary>
        public partial class __
        {
            /// <summary>编号</summary>
            public const String ID = "ID";

            /// <summary>名称</summary>
            public const String Name = "Name";

            public const String Author = "Author";
            /// <summary>源地址</summary>
            public const String BaseUrl = "BaseUrl";

            /// <summary>url地址</summary>
            public const String Url = "Url";

            /// <summary>更新时间</summary>
            public const String UpdateTime = "UpdateTime";

            /// <summary>备注</summary>
            public const String Remark = "Remark";

            public const string IsXiaoshuo = "IsXiaoshuo";
        }
        #endregion
    }
}